class Bomb(object):
    # 初始化碰撞
    def __init__(self, screen, type):
        self.screen = screen
        if type == "enemy":
            # 加载爆炸资源
            self.mImage = [pygame.image.load
                           ("enemy0_down" + str(v) + ".png") for v in range(1, 5)]
        else:
            self.mImage = [pygame.image.load
                           ("hero" + str(v) + ".png") for v in range(2, 6)]

        # 设置当前爆炸索引
        self.mIndex = 0
        # 爆炸设置
        self.mPos = [0, 0]
        # 是否可见
        self.mVisible = False

    def action(self, rect):
        # 触发爆炸方法draw
        # 爆炸的坐标
        self.mPos[0] = rect.left
        self.mPos[1] = rect.top
        # 打开爆炸的开关
        self.mVisible = True

    def draw(self):
        if not self.mVisible:
            return
        self.screen.blit(self.mImage[self.mIndex], (self.mPos[0], self.mPos[1]))
        self.mIndex += 1
        if self.mIndex >= len(self.mImage):
            # 如果下标已经到最后了 代表爆炸结束
            # 下标位置重置 mVisible重置
            self.mIndex = 0
            self.mVisible = False